package nowcoder.offer;

import java.util.Arrays;
import java.util.Collections;

/**
 * 扑克牌顺子
 *
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-08-28 15:26
 */
public class isContinuous {
    public boolean solution(int[] numbers){
        if (numbers == null || numbers.length <5)
            return false;
        int[] n = new int[14];
        Arrays.sort(numbers);

        int count0 = 0;
        int len  = numbers.length;
        int start = 0,end = numbers[len-1];
        boolean flag =true;
        for (int i = 0; i < len; i++) {
            if (numbers[i] == 0) {
                count0++;
            }else {
                if (flag){
                    start = numbers[i];
                    flag = !flag;
                }
                n[numbers[i]]++;
            }
        }

        int count1 = 0;
        for (int i = start; i <= end; i++) {
            if (n[i] == 0)
                count1++;
            else if (n[i] > 1) return false;
        }
        return count1 <= count0;
    }

    public static void main(String[] args) {
        System.out.println(new isContinuous().solution(new int[]{0,0,1,3,5}));
    }

}
